In this chapter we are going to discuss few ideas which can be used to optimize & enhance the performance of the python code.
Most of the ideas present below are nothing but good common sense.
In [ ]:
In [5]:
d = 10
def B():
d = 20
def C():
d = 30
return d
print(d)
return C
x = B()
print(x)
In [3]:
d = 10
def B():
d = 20
def C():
global d
d = 30
return d
return C
a = B()
print(a())
print(d)
In [6]:
d = 10
def B():
d = 20
def C():
nonlocal d
print(d)
d = 30
return d
return C
a = B()
print(a())
print(d)
In [ ]: